package com.bjsxt.socketdemo;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class InetTest {
    public static void main(String[] args) throws UnknownHostException {
        InetAddress inetAddress = InetAddress.getLocalHost();
        System.out.println(inetAddress.getHostAddress());
        System.out.println(inetAddress.getHostName());

        InetAddress inetAddress1 = InetAddress.getByName("www.baidu.com");
        System.out.println(inetAddress1.getHostName());
        System.out.println(inetAddress1.getHostAddress());

        InetAddress inetAddress2 = InetAddress.getByName("112.80.248.76");
        System.out.println(inetAddress2.getHostName());
        System.out.println(inetAddress2.getHostAddress()); //找不到


    }
}
